const GET = 'GET';
const POST = 'POST';
const PUT = 'PUT';
const FORM = 'FORM';
const DELETE = 'DELETE';

// const baseURL = 'http://47.99.35.240:18080';
const baseURL = 'https://www.sxjxasmyx.com/zl';
// const baseURL = 'https://www.xianzl.co/zl';
// const baseURL = 'http://192.168.2.116:8080';


function request(method, url, data,header) {
    return new Promise(function(resolve, reject) {
        let head = {
            'Content-type': header?header:'application/x-www-form-urlencoded'
        }
        wx.request({
            url: baseURL + url,
            method: method,
            data: method === POST ? data : data,
            header:head,
            success(res) {
                if (res.data.code == 0 || res.data.code == 200) {
                    resolve(res.data);
                } else {
                    reject();
                }
            },
            fail(err) {
                reject(err)
            }
        })
    })
}

const API = {
  getOpenid: (data) => request(GET, `jsapi/mini?jsCode=${data}`),
  getProjectTypeList: (data) => request(POST, `/sys/tprojecttype/allList`),
  getOpenId:(data) => request(POST, `/app/wxLogin`,data),
  getJiShiData:(data) => request(POST, `/weixin/getJIshiAndCiShu`,data,'application/json'),
  getProjectList:(data) => request(POST, `/sys/tproject/list`,data),
  getUserPhone:(data) => request(POST, `/app/wxGetPhone`,data),
  getOrderList:(data) => request(POST, `/weixin/getDingDanXin`,data,'application/json'),
  rechargeOrder:(data) => request(POST, `/weixin/recharge`,data,'application/json'),  
  becomeMember:(data) => request(POST, `/weixin/becomeMember`,data,'application/json'),  
  getMemberInfo:(data) => request(POST, `/weixin/getMemberInfo`,data,'application/json'),  
  getStaffInfo:(data) => request(POST, `/sys/tstaff/info/${data}`),  
  getIntegralInfo:(data) => request(POST, `/weixin/getIntegralInfo`,data,'application/json'),  
  getReserveNo:(data) => request(POST, `/weixin/getReserveNo`,data,'application/json'),  
  fendian:(data) => request(POST, `/weixin/wx_fendianlist`,data,'application/json'),  
  yuyue:(data) => request(POST, `/weixin/yuyue`,data,'application/json'),  
  yuyueList:(data) => request(POST, `/weixin/yuyueList`,data,'application/json'),  
  getXiaoFeiXinXi:(data) => request(POST, `/weixin/getXiaoFeiXinXi`,data,'application/json'),  
  testPay:(data) => request(POST, `/tOpenRoom/testPay`,data,'application/json'),  
  getpayList:(data) => request(POST, `/app/tcardrechargeinfo/getChargeCase`,data,'application/json'), 
  
  
};  
module.exports = {
  API: API
}